this._scrollView.set_policy(St.PolicyType.NEVER,
St.PolicyType.EXTERNAL);
this._adjustment = this._scrollView.vscroll.adjustment;
+ this._adjustment.connect('notify::value', adj => {
+ this._pageIndicators.setCurrentPosition(adj.value / adj.page_size);
+ });
this._pageIndicators = new PageIndicators.AnimatedPageIndicators();
this._pageIndicators.connect('page-activated',
if (!this.mapped) {
this._adjustment.value = this._grid.getPageY(pageNumber);
- this._pageIndicators.setCurrentPage(pageNumber);
+ this._pageIndicators.setCurrentPosition(pageNumber);
this._grid.currentPage = pageNumber;
return;
}
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
duration: time,
});
-
- this._pageIndicators.setCurrentPage(pageNumber);
}
_diffToPage(pageNumber) {
this._adjustment.value = 0;
this._grid.currentPage = 0;
this._pageIndicators.setNPages(this._grid.nPages());
- this._pageIndicators.setCurrentPage(0);
+ this._pageIndicators.setCurrentPosition(0);
return GLib.SOURCE_REMOVE;
});
}
this.add_child(this._pageIndicator);
this._pageIndicator.setReactive(false);
+ this._emojiPager.connect('notify::delta', () => {
+ this._updateIndicatorPosition();
+ });
+
let bottomRow = this._createBottomRow();
this.add_child(bottomRow);
+ this._curPage = 0;
this._emojiPager.setCurrentPage(0);
}
}
_onPageChanged(sectionLabel, page, nPages) {
+ this._curPage = page;
this._pageIndicator.setNPages(nPages);
- this._pageIndicator.setCurrentPage(page);
+ this._updateIndicatorPosition();
for (let i = 0; i < this._sections.length; i++) {
let sect = this._sections[i];
}
}
+ _updateIndicatorPosition() {
+ this._pageIndicator.setCurrentPosition(this._curPage -
+ this._emojiPager.delta / this._emojiPager.width);
+ }
+
_findSection(emoji) {
for (let i = 0; i < this._sections.length; i++) {
if (this._sections[i].first == emoji)
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
/* exported PageIndicators, AnimatedPageIndicators */
-const { Clutter, GLib, GObject, Meta, St } = imports.gi;
+const { Clutter, GLib, Graphene, GObject, Meta, St } = imports.gi;
const { ANIMATION_TIME_OUT, ANIMATION_MAX_DELAY_OUT_FOR_ITEM, AnimationDirection } = imports.ui.iconGrid;
+const INDICATOR_INACTIVE_OPACITY = 128;
+const INDICATOR_INACTIVE_OPACITY_HOVER = 255;
+const INDICATOR_INACTIVE_SCALE = 2 / 3;
+const INDICATOR_INACTIVE_SCALE_PRESSED = 0.5;
+
var INDICATORS_BASE_TIME = 250;
var INDICATORS_BASE_TIME_OUT = 125;
var INDICATORS_ANIMATION_DELAY = 125;
clip_to_allocation: true,
});
this._nPages = 0;
- this._currentPage = undefined;
+ this._currentPosition = 0;
this._reactive = true;
this._reactive = true;
}
button_mask: St.ButtonMask.ONE |
St.ButtonMask.TWO |
St.ButtonMask.THREE,
- toggle_mode: true,
- reactive: this._reactive,
- checked: pageIndex == this._currentPage });
- indicator.child = new St.Widget({ style_class: 'page-indicator-icon' });
+ reactive: this._reactive });
+ indicator.child = new St.Widget({
+ style_class: 'page-indicator-icon',
+ pivot_point: new Graphene.Point({ x: 0.5, y: 0.5 }),
+ });
indicator.connect('clicked', () => {
this.emit('page-activated', pageIndex);
});
+ indicator.connect('notify::hover', () => {
+ this._updateIndicator(indicator, pageIndex);
+ });
+ indicator.connect('notify::pressed', () => {
+ this._updateIndicator(indicator, pageIndex);
+ });
+ this._updateIndicator(indicator, pageIndex);
this.add_actor(indicator);
}
} else {
this.visible = this._nPages > 1;
}
- setCurrentPage(currentPage) {
- this._currentPage = currentPage;
+ _updateIndicator(indicator, pageIndex) {
+ let progress =
+ Math.max(1 - Math.abs(this._currentPosition - pageIndex), 0);
+
+ let inactiveScale = indicator.pressed
+ ? INDICATOR_INACTIVE_SCALE_PRESSED : INDICATOR_INACTIVE_SCALE;
+ let inactiveOpacity = indicator.hover
+ ? INDICATOR_INACTIVE_OPACITY_HOVER : INDICATOR_INACTIVE_OPACITY;
+
+ let scale = inactiveScale + (1 - inactiveScale) * progress;
+ let opacity = inactiveOpacity + (255 - inactiveOpacity) * progress;
+
+ indicator.child.set_scale(scale, scale);
+ indicator.child.opacity = opacity;
+ }
+
+ setCurrentPosition(currentPosition) {
+ this._currentPosition = currentPosition;
let children = this.get_children();
for (let i = 0; i < children.length; i++)
- children[i].set_checked(i == this._currentPage);
+ this._updateIndicator(children[i], i);
}
});